#include<bits/stdc++.h>
using namespace std;

char ch[15][15];
int cx, cy, fx, fy;

int dx[] = {-1, 0, 1, 0};
int dy[] = {0, 1, 0, -1};

int d1, d2;

void move() {
	int x1 = cx + dx[d1];
	int y1 = cy + dy[d1];
	if (ch[x1][y1] != '.')
		d1 = (d1 + 1) % 4;
	else
		cx = x1, cy = y1;

	int x2 = fx + dx[d2];
	int y2 = fy + dy[d2];
	if (ch[x2][y2] != '.')
		d2 = (d2 + 1) % 4;
	else
		fx = x2, fy = y2;
}

signed main() {
	for (int i = 1; i <= 10; i++) {
		for (int j = 1; j <= 10; j++) {
			cin >> ch[i][j];
			if (ch[i][j] == 'C')
				cx = i, cy = j, ch[i][j] = '.';
			if (ch[i][j] == 'F')
				fx = i, fy = j, ch[i][j] = '.';
		}
	}

	int cnt = 0;
	while (1) {
		if (cnt > 100000)
			break;

		cnt++;
		move();

		if (cx == fx && cy == fy) {
			cout << cnt;
			return 0;
		}
	}
	cout << 0;
	return 0;
}
